function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
	
	draw.SimpleText( "j", "CSSelectIcons", x + wide/2, y + tall*0.2, Color( 255, 110, 0, 255 ), TEXT_ALIGN_CENTER )
	draw.SimpleText( "j", "CSSelectIcons", x + wide/2 + math.Rand(-4, 4), y + tall*0.2+ math.Rand(-9, 9), Color( 255, 110, 0, math.Rand(10, 120) ), TEXT_ALIGN_CENTER )
	
end

if ( CLIENT ) then

	SWEP.ViewModelFOV		= 72
	SWEP.ViewModelFlip		= false
	SWEP.CSMuzzleFlashes	= false
	
	killicon.AddFont( "weapon_stalkerknife", "CSKillIcons", "j", Color( 255, 80, 0, 255 ) )

end

SWEP.Author = "";
SWEP.Contact = "";
SWEP.Purpose = "";
SWEP.Instructions = ""; 

SWEP.Spawnable			= false
SWEP.AdminSpawnable		= true

SWEP.Primary.Recoil			= 1.25
SWEP.Primary.Damage			= 50
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.02
SWEP.Primary.Delay			= .81

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.Delay		= .5
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= true
SWEP.Secondary.Ammo			= "none"

SWEP.ViewModel = "models/weapons/v_knife_t.mdl"
SWEP.WorldModel = "" --NONE

util.PrecacheSound("weapons/knife/knife_hitwall1.wav")
util.PrecacheSound("weapons/knife/knife_slash1.wav")
util.PrecacheSound("weapons/knife/knife_stab.wav")
util.PrecacheSound("weapons/knife/knife_deploy1.wav")
util.PrecacheSound("ambient/machines/slicer1.wav")
util.PrecacheSound("ambient/machines/slicer4.wav")
util.PrecacheSound("ambient/machines/slicer2.wav")
util.PrecacheSound("npc/stalker/go_alert2.wav") -- REEEH
util.PrecacheSound("UI/buttonclickrelease.wav") -- Stealth noise
 
util.PrecacheSound("physics/flesh/flesh_impact_bullet2.wav") -- Stealth noise
 
function SWEP:Deploy()
self.Weapon:EmitSound("weapons/knife/knife_deploy1.wav")
self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY )
heldent = nil
end

function SWEP:Initialize()
    if (CLIENT) then return end
    self:SetWeaponHoldType("slam")
	heldent = nil
end 

function SWEP:OwnerChanged()
	heldent = nil
end
 
function SWEP:Reload()
   heldent = nil
end
 
function SWEP:Think()
if heldent == nil then return end
 
local ent = heldent

    if (!ent:IsValid()) then
        heldent = nil
    else
	
    local pos = self.Owner:GetShootPos()
    local ang = self.Owner:GetAimVector() + Vector(0,0,0.13) 
    ent:SetPos(pos+(ang*49))
	
	end
end

 function SWEP:PrimaryAttack()
 
 self.Weapon:SetNextPrimaryFire( CurTime() + 0.55 )
 
 self.Owner:LagCompensation(true)

 local trace = util.GetPlayerTrace(self.Owner)
 local tr = util.TraceLine(trace)
 local trlength = self.Weapon:GetOwner():GetPos() - tr.HitPos //tr.Entity:GetPos()
	   trlength = trlength:Length() 
	   
 self.Owner:LagCompensation(false)
	   
	if trlength <= 100 then

		if tr.HitWorld then 
	
		util.Decal("ManhackCut", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)
		self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
		self.Weapon:EmitSound(Sound("weapons/knife/knife_hitwall1.wav"))
		self.Weapon:EmitSound(Sound("weapons/knife/knife_slash1.wav"))
		self.Owner:ViewPunch(Angle( math.Rand(-3,3) * self.Primary.Recoil, math.Rand(-3,3) * self.Primary.Recoil, 0 ) )

		elseif tr.Entity:IsPlayer() then
		
		self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
		self.Owner:ViewPunch(Angle( math.Rand(-3,3) * self.Primary.Recoil, math.Rand(-3,3) * self.Primary.Recoil, 0 ) )
		
		util.Decal("Blood", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)
		
		for  k, pl in pairs(player.GetAll()) do
			if tr.Entity:GetPos() == pl:GetPos() then
				if (SERVER) then
					if tr.Entity:Health() >= 51 then
						tr.Entity:EmitSound(RandomSound(StabHurt))
					end
				pl:TakeDamage(self.Primary.Damage,self.Weapon:GetOwner()) 
				end
			end
		end
		
		local ksound = Sound(RandomSound(Wep_Slice))
		
		self.Weapon:EmitSound(ksound)
		//tr.Entity:EmitSound(ksound)
		self.Weapon:EmitSound(Sound("weapons/knife/knife_slash1.wav"))
	
		else
		
		local physobj = tr.Entity:GetPhysicsObject()
		
			if physobj:IsValid() then
	
				if heldent == nil and physobj:GetMass() <= 370 and !tr.Entity:IsConstrained() and !tr.Entity:IsPlayer() then
				
				heldent = physobj
				physobj:ApplyForceCenter(self.Owner:GetAimVector() * 666)
				
				tr.Entity:SetCollisionGroup( COLLISION_GROUP_WEAPON )
				
				elseif heldent then
				
				self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
				
					if tr.Entity:GetModel() == "models/police.mdl" then
					
					tr.Entity:SetCollisionGroup( COLLISION_GROUP_WEAPON )
					self.Owner:EmitSound(Sound("physics/flesh/flesh_impact_bullet2.wav"),100,120)
					
					else
					
					tr.Entity:SetCollisionGroup( COLLISION_GROUP_NONE )
					self.Weapon:EmitSound(Sound("weapons/knife/knife_hitwall1.wav"))
					
					end
				
				self.Weapon:EmitSound(Sound("weapons/knife/knife_slash1.wav"))
				
				physobj:ApplyForceCenter(self.Owner:GetAimVector() * 30000)
				
				heldent = nil
				
					if ( trTwo.Hit and !trTwo.Entity:IsPlayer() and tr.Entity:GetModel() == "models/police.mdl" ) then
					
					//Msg("IT IS A POLICE MAN\n")
				
					local vOrigin = tr.HitPos - (self.Weapon:GetOwner():GetAimVector() * 6.0)
					local vDirection = self.Weapon:GetOwner():GetAimVector():Angle()
					
					tr.Entity:SetPos(tr2.endpos)
					util.Decal("Blood", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)

					vOrigin = tr.Entity:WorldToLocal( vOrigin )
				
					local constraint = CorpsePin( tr.Entity, trTwo.Entity, tr.PhysicsBone, trTwo.PhysicsBone, 0, vOrigin, vDirection )
					end
				end
			end
		end
	end
 end
 
 
 function CorpsePin( Ent1, Ent2, Bone1, Bone2, forcelimit, Pos, Ang )

	local constraint = constraint.Weld( Ent1, Ent2, Bone1, Bone2, forcelimit )

	return constraint
end
  

 function SWEP:SecondaryAttack()
	
 end